package com.book.domain;

public class SplitPage {

	int totalpagenumber; //总页面数
	static int currentpagenumber; //当前页面数字
	int nextpagenumber; //下一页面数字
	int lastpagenumber;//上一页面数字
	int pagerecordnumber; //每页记录数
	int beginrecord; //开始记录
	int endrecord;//结束记录
	static int totalrecord;//总记录数
	int beginpage; //开始页面数字
	int endpage;//结束页面数字
	public int getBeginpage() {
		return beginpage;
	}

	public void setBeginpage(int beginpage) {
		this.beginpage = beginpage;
	}

	public int getEndpage() {
		return endpage;
	}

	public void setEndpage(int endpage) {
		this.endpage = endpage;
	}

	

	@Override
	public String toString() {
		return "SplitPage [totalpagenumber=" + totalpagenumber
				+ ", currentpagenumber=" + currentpagenumber
				+ ", nextpagenumber=" + nextpagenumber + ", lastpagenumber="
				+ lastpagenumber + ", pagerecordnumber=" + pagerecordnumber
				+ ", beginrecord=" + beginrecord + ", endrecord=" + endrecord
				+ ", beginpage=" + beginpage + ", endpage=" + endpage + "]";
	}

	public int getTotalpagenumber() {
		return totalpagenumber;
	}

	public void setTotalpagenumber(int totalpagenumber) {
		this.totalpagenumber = totalpagenumber;
	}

	public int getCurrentpagenumber() {
		return currentpagenumber;
	}

	public void setCurrentpagenumber(int currentpagenumber) {
		this.currentpagenumber = currentpagenumber;
	}

	public int getNextpagenumber() {
		return nextpagenumber;
	}

	public void setNextpagenumber(int nextpagenumber) {
		this.nextpagenumber = nextpagenumber;
	}

	public int getLastpagenumber() {
		return lastpagenumber;
	}

	public void setLastpagenumber(int lastpagenumber) {
		this.lastpagenumber = lastpagenumber;
	}

	public int getPagerecordnumber() {
		return pagerecordnumber;
	}

	public void setPagerecordnumber(int pagerecordnumber) {
		this.pagerecordnumber = pagerecordnumber;
	}

	public int getBeginrecord() {
		return beginrecord;
	}

	public void setBeginrecord(int beginrecord) {
		this.beginrecord = beginrecord;
	}

	public int getEndrecord() {
		return endrecord;
	}

	public void setEndrecord(int endrecord) {
		this.endrecord = endrecord;
	}

	public int getTotalrecord() {
		return totalrecord;
	}

	public void setTotalrecord(int totalrecord) {
		this.totalrecord = totalrecord;
	}

	public static SplitPage calculatepage(SplitPage spliPageold) {
		SplitPage spliPagenew = new SplitPage();

		int totalre = spliPageold.getTotalrecord();
		int currentpage = spliPageold.getCurrentpagenumber();
		int beginpage = 0;
		int endpage=0;
		if (currentpage < 5) {
			beginpage = 1;
		} else {
			beginpage = currentpage - 5 + 1;
		}
		int totalpage=0;
        if(totalre%(spliPageold.getPagerecordnumber())==0){
        	 totalpage = totalre / spliPageold.getPagerecordnumber();
        }else{
        	 totalpage = totalre / spliPageold.getPagerecordnumber() + 1;
        }
		
		if(currentpage+5>totalpage){
			endpage=totalpage;
		}else {
			endpage=currentpage+5;
		}
       
		if (currentpage*spliPageold.getPagerecordnumber()<totalre) {
			spliPagenew.setBeginrecord((currentpage-1)*spliPageold.getPagerecordnumber()+1);
			spliPagenew.setEndrecord(currentpage*spliPageold.getPagerecordnumber());
		}else {
			spliPagenew.setBeginrecord((currentpage-1)*spliPageold.getPagerecordnumber()+1);
			spliPagenew.setEndrecord(totalrecord);
		}
		spliPagenew.setTotalpagenumber(totalpage);
		spliPagenew.setCurrentpagenumber(currentpage);
		spliPagenew.setBeginpage(beginpage);
		spliPagenew.setEndpage(endpage);
		spliPagenew.setCurrentpagenumber(currentpagenumber);
		return spliPagenew;
	}
	

}
